<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><{$tpl_title}><{T w='Content Management System'}></title>
<link href="<{$smarty.const.BASEPATH}>/css/base.css" rel="stylesheet"/>
<link href="<{$smarty.const.BASEPATH}>/css/admin_style.css" rel="stylesheet"/>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/pinyin.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/jquery.min.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/validform/js/Validform.min.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>xheditor/xheditor-zh-cn.min.js"></script>
<script type="text/javascript">
$(pageInit);
function pageInit()
{
	$.extend(xheditor.settings,{forcePtag:false,skin:'nostyle',shortcuts:{'ctrl+enter':submitForm}});//修改默认设置
	$('#categories_description').xheditor({urlType:'rel',upLinkUrl:"!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=附件文件(*.zip;*.rar;*.txt)",upImgUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=图片文件(*.jpg;*.jpeg;*.gif;*.png)',upFlashUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=Flash动画(*.swf)',upMediaUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=多媒体文件(*.wmv;*.avi;*.wma;*.mp3;*.mid)',onUpload:insertUpload});
    $('#upimg').xheditor({skin:'upfile',tools:'Img',urlType:'root',upLinkUrl:"!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=附件文件(*.zip;*.rar;*.txt)",upImgUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=图片文件(*.jpg;*.jpeg;*.gif;*.png)',upFlashUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=Flash动画(*.swf)',upMediaUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{$smarty.const.WEBDIR}>upload.php%3Fimmediate%3D1&ext=多媒体文件(*.wmv;*.avi;*.wma;*.mp3;*.mid)',onUpload:insertUpload});
}
function submitForm(){$('#frmDemo').submit();}
function insertUpload(arrMsg)
{
	var i,msg;
	for(i=0;i<arrMsg.length;i++)
	{
		msg=arrMsg[i];
		$("#uploadList").append('<option value="'+msg.newFilename+'">'+msg.newFilename+'</option>');
	    //$("#imglist").append('<img src="\/upload\/'+msg.newFilename+'" width=100>');
        //document.getElementById('allimg').value=document.getElementById('allimg').value+''+msg.newFilename;
        if($("#allimg").val()==""){
        $("#allimg").val($("#allimg").val()+msg.newFilename);
        }else{
        $("#allimg").val($("#allimg").val()+'|'+msg.newFilename);
        }
    }
}
function insertUpload2(file)
{
	$("#uploadList").append('<option value="'+file+'" selected="selected">'+file+'</option>');
        if($("#allimgx").val()==""){
        $("#allimg").val($("#allimg").val()+file);
        }else{
        $("#allimg").val($("#allimg").val()+'|'+file);
        }
}

$(function(){ // 当页面加载完毕的时候
	$(".form:last").Validform({
		tiptype:2,
		ajaxPost:true,
		callback:function(data){
			if(data.status=="y"){
				setTimeout(function(){
					$.Hidemsg(); //公用方法关闭信息提示框;
                    //parent.location.reload();
                    location.href="<{spUrl c=categories a=index}>";
				},2000);
                
			}
		}
	});    
});
function TS()
{
 var ts =$('#categories_title').val();
            $('#categories_name').val(ts);
}
function ZH()
{
 var teststr =ConvertPinyin($('#categories_name').val());
            teststr = teststr.replace(/[^A-z0-9]/g,"-");
            teststr = teststr.replace(/[_*&^]/g,"-");
            teststr = teststr.replace(/--/g,"-");
            teststr = teststr.replace(/-$/g,"");
          $('#categories_alias').val(teststr);
}

</script>

</head>
<body>
<form class="form" action="<{spUrl c=categories a=save}>" method="post"> 
   <table class="tab_list">
   <caption><a href="#">◆<{$addtitle}></a></caption>

   <tr>
    <td width="60">所属分类:</td>
    <td>
        <select name="parent_id" id="parent_id">
        <option value="0">顶级分类</option>
        <{function name=menu level=0}> 
        <{for $i=0 to $i<$level*2-1}>    
        <{$str=$str|cat:'　'}>
        <{/for}>
        <{if $level++}>
        <{$str2= $str|cat:'├'}>
        <{/if}>
        <{foreach $data as $entry}> 
        <option value='<{$entry.categories_id}>' <{if $entry.categories_id==$parent_id}>selected='selected'<{/if}>><{$str2}><{$entry.detail.categories_name}></option>
        <{if isset($entry.child)}>             
        <{call name=menu data=$entry.child level=$level}>           
        <{/if}> 
        <{/foreach}>  
        <{/function}> 
        
        <{call name=menu data=$arr}>
        </select>
    </td>
   </tr>
   <tr>
    <td>网页标题:</td>
    <td>
        <input type="text" name="categories_title" id="categories_title" value="<{$categorie.detail.categories_title}>" class="inputxt" datatype="*" nullmsg="请输入标题！" />
        </td>
   </tr>
   <tr>
    <td>分类名称:</td>
    <td>
        <input type="hidden" name="categories_id" id="categories_id" value="<{$categorie.categories_id}>"/>
        <input type="text" name="categories_name" id="categories_name" value="<{$categorie.detail.categories_name}>" class="inputxt"  datatype="*" nullmsg="请输入名称！"/><button name="tm" onClick="TS()" type="button">同上</button>
    </td>
   </tr>
   <tr>
    <td>URL映射:</td><td>
    <input type="text" name="categories_alias" id="categories_alias" value="<{$categorie.alias}>" class="inputxt" ajaxurl="<{spUrl c=categories a=checkalias cid=$categorie.categories_id}>" datatype="*" errormsg="别名不能为空！" nullmsg="请输入网址别名！" /><button name="btzf" onClick="ZH()" type="button">名称转换</button></td>
   </tr>
   <tr>
    <td>关 键 字 :</td><td><input type="text" name="categories_keywords" id="categories_keywords" value="<{$categorie.detail.categories_keywords}>"/> 多个关键字用英文逗号隔开</td>
   </tr>
   <tr>
    <td>网页描述:</td><td><textarea name="categories_meta_description" id="categories_meta_description" style="width: 59%;"><{$categorie.detail.categories_meta_description}></textarea></td>
   </tr>
   <tr>
     <td>分类描述:</td>
     <td>
     <textarea name="categories_description" id="categories_description" rows="8" style="width: 60%;"><{$categorie.detail.categories_description}></textarea></td>
   </tr>
        <tr>
            <td>主图:</td>
            <td><input type="hidden" name='allimg' id='allimg' value="<{$img}>"/>
            <select id="uploadList" name="uploadList" style="width:310px;float:left;" onChange="document.viewimg.src='<{$smarty.const.WEBDIR}>upload/'+options[selectedIndex].value">
            
            <option value="" selected="selected">选择并上传图片</option>
            <{if $categorie.allimg neq ""}>
            <{foreach $allimg as $img2}>
            <option value="<{$img2}>" <{if $img2 eq $categorie.image}>selected="selected"<{/if}>><{$img2}></option>
            <{/foreach}>
            <{/if}>
            
            </select> <textarea name="upimg" id="upimg" style="float:left;width: 25px;height:0px;"></textarea>
            <label><a href="#" onclick="document.getElementById('jtdiv').style.display='block';document.getElementById('jt').src='<{spUrl c=main a=jt}>&cropw=225&croph=133&pic=upload\/'+document.getElementById('uploadList').options[document.getElementById('uploadList').selectedIndex].value;">[ 切225-高133] </a></label></td>
        </tr>
   <tr>
    <td>显示排序:</td><td><input type="text" name="sort_order" id="sort_order" value="<{$categorie.sort_order}>"/></td>
   </tr>
        <tr>
        <td></td>
        <td colspan="2" id="imglist"><img id="viewimg" src="upload/<{$categorie.image}>" onerror="this.src='<{$smarty.const.WEBDIR}>404/no.gif'" name="viewimg" alt="选择你要显示的图片" height="100"/></td>
        </tr>
   </table>
    <div id="jtdiv" style="display: none;">
    <iframe  border=0 frameborder=0 framespacing=0 height='330' marginheight=0  marginwidth=0 name=jt id=jt scrolling=no 
 src="" width='700' vspale="0"></iframe>
    </div>
   <div id="submit_float">
   <input type="submit" value="提交" name="newqx" id="newqx"/> <input type="reset" value="重置"/></div>
   </div>
</form>
<br /><br /><br />
</body></html>